package factory.controller;

import dataStandardCatalog.domain.DataStandardCatalog;
import dataStandardCatalog.dto.AddDataStandardCatalogDTO;
import dataStandardCatalog.dto.DataStandardCatalogDTO;
import dataStandardCatalog.vo.ClickOnStandardLableVO;
import factory.service.DataStandardCatalogService;
import factory.service.DatabaseManageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import result.PageDTO;
import result.R;

@Slf4j
@RestController
@Tag(name = "数据标准目录",description = "数据标准目录")
@RequestMapping("/DataStandardCatalog")
public class DataStandardCatalogController {
    @Resource
    private DataStandardCatalogService dataStandardCatalogService;

    @Operation(summary = "查询数据标准目录",description = "查询数据标准目录")
    @PostMapping("/pageAll")
    public R pageAll(@RequestBody PageDTO pageDTO){
        return R.OK(dataStandardCatalogService.pageAll(pageDTO));
    }

    @Operation(summary = "条件查询数据标准目录",description = "条件查询数据标准目录")
    @PostMapping("/pageDatabaseByQuery")
    public R pageAllByQuery(@RequestBody DataStandardCatalogDTO dataStandardCatalogDTO){
        return R.OK(dataStandardCatalogService.pageAllByQuery(dataStandardCatalogDTO));
    }

    @Operation(summary = "根据标准编号得到表",description = "根据标准编号得到表")
    @PostMapping("/clickOnOne/{id}")
    public R ClickOnOne(@PathVariable Integer id){
        return R.OK(dataStandardCatalogService.ClickOnOne(id));
    }

    @Operation(summary = "新增数据标准",description = "新增数据标准")
    @PostMapping("/addDataStandard")
    public R addDataStandard(@RequestBody AddDataStandardCatalogDTO addDataStandardCatalogDTO){
        return dataStandardCatalogService.addDataStandard(addDataStandardCatalogDTO)?R.OK():R.FAIL();
    }

    @Operation(summary = "删除数据标准",description = "删除数据标准")
    @PostMapping("/deleteDataStandard")
    public R addDataStandard(Integer id){
        return dataStandardCatalogService.removeById(id)?R.OK():R.FAIL();
    }

    @Operation(summary = "修改状态",description = "修改状态")
    @PostMapping("/updateStatic")
    public R updateStatic(Integer id){
        return dataStandardCatalogService.updateStatic(id)?R.OK():R.FAIL();
    }


}
